package com.basic.util;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class NetStateTool {
	
	/**
	 * 判断网络是否开启 
	 * @param context
	 * @return
	 */
	public static boolean isNetWorkingEnable(Context context){
		ConnectivityManager cm = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo[] networkInfos = cm.getAllNetworkInfo();
		for (NetworkInfo networkInfo : networkInfos) {
			if(networkInfo.isAvailable()) return true;
		}
		return false;
	}
}
